package com.sojpt.boot.controller.business.validator;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;
import com.sojpt.model.LkyCollege;

public class LkyCollegeAddValidator extends Validator {

    @Override
    protected void validate(Controller c) {

        LkyCollege lkyCollege = c.getModel(LkyCollege.class, "lkyCollege");

        if(lkyCollege.get("name") != null)
            validateString("lkyCollege.name", 0, 20, "msg", "学院名称 最多20个字符");
        validateRequired("lkyCollege.name", "msg", "请输入学院名称");
        if(lkyCollege.get("collage_number") != null)
            validateString("lkyCollege.collage_number", 0, 20, "msg", "学院编号 最多20个字符");
        validateRequired("lkyCollege.collage_number", "msg", "请输入学院编号");


    }

    @Override
    protected void handleError(Controller c) {
        c.renderJson();
    }

}